# -*- coding: utf-8 -*- 
# @project : 《Atcoder》
# @Author : created by bensonrachel on 2021/9/13
# @File : D - KAIBUNsyo-方法二（回文序列，图，连通分量，DSU）.py
import sys

sys.setrecursionlimit(80000)
# from collections import deque
# 用了deque反而超时了，真奇怪，插入速度快 remove和获取索引的时候比较慢
N = 2*10**5+1

class dsu:

    def __init__(self):
        """
        Initialize your data structure here.
        """
        self.s = [-1]*(N)
        # 不能用deque代替list 查找队列中间的元素较为缓慢，涉及加减元素和两端操作才快。

    def get_Leader(self,x: int):
        """

        """
        if(self.s[x] < 0):
            return x #返回的是下标
        self.s[x] = self.get_Leader(self.s[x])
        return self.s[x]

    def merge(self,a:int,b:int):
        """
        小的CC加入大的CC，按秩
        :param a:
        :param b:
        :return:
        """
        x, y = self.get_Leader(a),self.get_Leader(b)
        if(x==y):return x
        if(-self.s[x] < -self.s[y]):
            x ,y = y, x
        self.s[x] += self.s[y]
        self.s[y] = x
        return x

    def same(self,a:int,b:int) -> bool:
        """
        是否在同一个连通分量中
        :param a:
        :param b:
        :return: 是/否
        """
        return self.get_Leader(a)==self.get_Leader(b)

    def cnt_Connected_Component_size(self,x):
        """

        :return:
        """
        return -self.s[self.get_Leader(x)]

def solve():
    l = 0
    r = n-1
    d = dsu()
    s = [False]*(N)#用set也行
    res = 0
    while(l<r):# 先作图
        if(rate[l] != rate[r]):
            d.merge(rate[l],rate[r])
        l += 1
        r -= 1
    for i in range(n//2):
        root = d.get_Leader(rate[i])
        if(s[root]):continue
        s[root]=True
        res += d.cnt_Connected_Component_size(root) - 1
    return res


def solve1():
    """
    用到了dsu的same
    :return:
    """
    d = dsu()
    res = 0
    for i in range(n // 2):
        if(rate[i] != rate[n - 1 - i]):
            if(not d.same(rate[i],rate[n - 1 - i])):
                res += 1
                d.merge(rate[i],rate[n - 1 - i])
    return res

"""
DSU做法。
"""
if __name__ == '__main__':
    n = int(input())
    rate = [int(i) for i in input().split()]
    ans = solve()
    print(ans)